﻿using SortingAlgorithms.Exchange;
using SortingAlgorithms.Insertion;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SortingAlgorithms
{
    class Program
    {
        static void Main(string[] args)
        {
            #region 冒泡排序
            int[] bubbleArray = { 6, 5, 3, 1, 8, 7, 2, 4 };    // 从小到大冒泡排序
            int n = bubbleArray.Length;
            Console.WriteLine("冒泡排序数组：");
            for (int i = 0; i < n; i++)
            {
                Console.Write(bubbleArray[i] + "   ");
            }
            Console.Write("\n");
            BubbleSort.Instance.SortAsc(bubbleArray, n);
            Console.WriteLine("冒泡排序结果：");
            for (int i = 0; i < n; i++)
            {
                Console.Write(bubbleArray[i] + "   ");
            }
            Console.Write("\n");
            Console.WriteLine("------------------分割线---------------------");
            #endregion

            #region 鸡尾酒排序
            int[] cocktailArray = { 6, 5, 3, 1, 8, 7, 2, 4 };   // 从小到大定向冒泡排序
            n = cocktailArray.Length;
            Console.WriteLine("鸡尾酒排序数组：");
            for (int i = 0; i < n; i++)
            {
                Console.Write(cocktailArray[i] + "   ");
            }
            Console.Write("\n");
            CocktailSort.Instance.SortAsc(cocktailArray, n);
            Console.WriteLine("鸡尾酒排序结果：");
            for (int i = 0; i < n; i++)
            {
                Console.Write(cocktailArray[i] + "   ");
            }
            Console.Write("\n");
            Console.WriteLine("------------------分割线---------------------");
            #endregion

            #region 插入排序
            int[] insertArrayDesc = { 3, 1, 5, 7, 2, 4, 9, 6 };
            n = insertArrayDesc.Length;
            Console.WriteLine("插入排序数组：");
            for (int i = 0; i < n; i++)
            {
                Console.Write(insertArrayDesc[i] + "   ");
            }
            Console.Write("\n");
            InsertionSort.Instance.SortDesc(insertArrayDesc, n);
            Console.WriteLine("插入排序倒序结果：");
            for (int j = 0; j < n; j++)
            {
                Console.Write(insertArrayDesc[j] + "   ");
              
            }
            Console.Write("\n");

            int[] insertArrayAsc = { 3, 1, 5, 7, 2, 4, 9, 6 };

            InsertionSort.Instance.SortAsc(insertArrayAsc, n);
            Console.WriteLine("插入排序倒序结果：");
            for (int k = 0; k < n; k++)
            {
                Console.Write(insertArrayAsc[k] + "   ");
            }
            Console.Write("\n");
            Console.WriteLine("------------------分割线---------------------");

            #endregion

            Console.ReadLine();
        }
    }
}
